﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using ueEngine.Biz.Inf.Entities.DBSupport;
using ueEngine.Framework.Exception;

namespace ueEngine.Biz.Inf.Entities
{
    [Table("Attention")]
    public class Attention : BaseEntity<Attention>
    {
        public Attention() { }
        public override Attention Get(System.Linq.Expressions.Expression<Func<Attention, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.Attention.FirstOrDefault(where);
                if (item != null)
                {
                    this.AddDate = item.AddDate;
                    this.AttentionType = item.AttentionType;
                    this.Id = item.Id;
                    this.Master = item.Master;
                    this.Target = item.Target;
                    return this;
                }
                return null;
            }
        }
        #region 
        [Column(TypeName = "int")]
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 关注分类
        /// </summary>
        [Column(TypeName="int")]
        public int AttentionType { get; set; }

        /// <summary>
        /// 关注事件的发起者
        /// </summary>
        [Column(TypeName="nvarchar")]
        [StringLength(200)]
        public string Master { get; set; }

        /// <summary>
        /// 被关注的对象
        /// </summary>
        [Column(TypeName="nvarchar")]
        [StringLength(200)]
        public string Target { get; set; }

        [Column(TypeName="datetime")]
        public DateTime AddDate { get; set; }
        #endregion
    }
}
